import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import routesLoader from "./router";

Vue.use(VueRouter)

const routes: Array<RouteConfig> = routesLoader();


const router = new VueRouter({
  // mode: 'history',
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

// 路由守卫
router.beforeEach((to, from, next) => {
  /* 必须调用 `next` */
  console.log('@@beforeEach@@', to, from, next)
  next()
})

export default router